#include <IDK.hpp>

#include <RenderState.hpp>
#include <OccluderFrustum.hpp>

namespace Renderer
{
	//-------------------------------------------------------
	// TRenderState
	//-------------------------------------------------------
	TRenderState::TRenderState(void)
		: mCullFace(CullFace::MAX),
		mBlend(Blend::MAX),
		mDepthTest(DepthTest::MAX),
		mOccluder(new TOccluderFrustum()),
		mResources(new Array<IDK::GPUResource>::Create()),
		mTimeFrame(0),
		mTimeElapsed(0)
	{
	}

	ref<IDK::IOcclusionQuery> TRenderState::GetOcclusionQuery(void)
	{
		return mOccluder;
	}

	void TRenderState::SetMatrix(MatrixType::Enum type, const Math::Matrix44& m)
	{
		mMatrices[type] = m;
		mMatricesChanged.Include(type);
	}

	void TRenderState::Reset()
	{
		for(Resources::Iterator it = mResources->Begin(), end = mResources->End();
			it!=end;
			++it)
		{
			it->Dispose();
		}
	}

	void TRenderState::Swap(float dt)
	{
		mTimeElapsed += (mTimeFrame = dt);
	}
}